home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 August (Alt) / CHIP 2005-08.1.iso / program / guvenlik / syslinux-3.07.exe / menu / startup.S16 < prev    next >
Encoding:
Text File  |  2004-02-03  |  720 b   |  38 lines

  1.     .code16gcc
  2.  
  3.     .globl _start
  4. _start:
  5.     /* Make sure stack pointer is normalized */
  6.     movzwl %sp,%esp
  7.  
  8.     /* Zero .bss */
  9.     movw $__bss_start,%di
  10.     xorl %eax,%eax
  11.     movw $(_end+3),%cx
  12.     subw %di,%cx
  13.     shrw $2,%cx
  14.     cld
  15.     rep ; stosl
  16.  
  17.     /* Normalize the command line.  At startup 0x80 = length and
  18.        the command line starts at 0x81, but with whitespace */
  19.     movl $0x81,%esi
  20.     movzbw (0x80),%bx
  21.     movb $0,(%bx,%si)        /* Null-terminate the string */
  22. 1:
  23.     lodsb
  24.     dec %al                /* Stop on null */
  25.     cmp $31,%al            /* Whitespace? */
  26.     jbe 1b
  27.     dec %si                /* Unskip first character */
  28.  
  29.     /* Invoke _cstart */
  30.     pushl %esi            /* Pointer to command line */
  31.     calll _cstart
  32.  
  33.     /* Terminate program (with error code in %al) */
  34.     movb $0x4c,%ah
  35.     int $0x21
  36.     hlt
  37.  
  38.